package com.wxyzz.common.core.config;


import com.wxyzz.common.core.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * --- 加油，努力 ---
 *
 * @Author XYP
 * @Date 2024/10/28
 * @Solgne 从想做到能做
 * @Desc 拦截器配置类
 */
@Configuration // 这个注解,让springboot框架知道,以下的这个类是提供配置
public class MyWebMvcInterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] excludePatterns = new String[]{
                "/swagger-resources/**",
                "/webjars/**",
                "/v3/**",
                "/swagger-ui.html",
                "/swagger-ui/**",
                "/api-docs/**",
                "/doc.html"};
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**") // 拦截所有
                .excludePathPatterns(excludePatterns);
    }
}
